<template>
  <div>
      <input type="text" v-model="val" placeholder="请输入金额">
      <div>皇冠体育<span v-if='val'>{{val}}</span><span v-else>{{couNum==0?"":couNum}}</span></div>
      <button @click='btn(val)'>转</button>

      <!-- div控制数据 -->
      <!-- <div class="div_ul">
        <ul>
          <li v-for="item in arr">{{item}}</li>
        </ul>
      </div> -->
      <child :arr=arr></child>
  </div>
</template>
<script>
  import child from './child.vue'
  export default{
    data(){
      return{
        val:'',
        couNum:'',
        arr:[1,2,4,5,6,7,8,9]
      }
    },
    components:{
      child
    },
    created(){
      // setInterval(()=>{
      //   this.setArr();
      // },2000)
    },
    methods:{
      setArr(){
        this.arr.push(1);
        console.log(this.arr);
      },
      btn(val){
        this.val='';
        this.couNum=+val;
        // var arr=[];  //新数组
        // var sum=0;  //总和
        // for(var i=0;i<this.topList.length;i++){
        //   for(var j=0;j<this.topList[i].data.length;j++){
        //     sum+=parseInt(this.topList[i].data[j])
        //   }
        //   arr.push(sum%4)
        // }

      },
      time(){
          this.totalNum=0;
          for(var i=0;i<this.topList[0].data.length;i++){
            this.totalNum+=parseInt(this.topList[0].data[i]);
          }
            this.yuNum=this.totalNum%4==0?4:this.totalNum%4;

            var sum=0;  //总和
            var timeDate=new Date();
            var year=timeDate.getFullYear();
            var mouth=timeDate.getMonth()+1<10?'0'+(timeDate.getMonth()+1):timeDate.getMonth()+1;
            var day=timeDate.getDate()<10?'0'+timeDate.getDate():timeDate.getDate();
            var full=parseInt(year+''+mouth+''+day);

            this.lits_biao=[]; //shixiashixia试下
            console.log(this.topList)
            for(var i=0;i<this.topList.length;i++){
              if(full==this.setTime(this.topList[i].time)){  //大于昨天时间
                for(var j=0;j<this.topList[i].data.length;j++){
                  sum+=parseInt(this.topList[i].data[j])
                }
                this.lits_biao.push(sum%4==0?4:sum%4)
              }else{
                continue;
              }

              // if(this.topList[i].time)


            }
            this.lits_biao=this.lits_biao.reverse();
            console.log(this.lits_biao.length);
      },
      setTime(time){
        var str=time.split(' ')[0].split('-');
        return parseInt(str[0]+str[1]+str[2]);  //20180612格式
      }
    }
  }
</script>
<style>
  *{
    margin:0;
    padding:0;
    box-sizing: border-box;
  }
  .div_ul{
    width:200px;
    height:200px;
    border:1px solid red;
    /* overflow: hidden; */
  }
  ul{
    list-style: none;
    height: inherit;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
  }
  li{
    /* float:left; */
    /* display: inline-block; */
    width:20px;
    height:20px;
    border:1px solid #ccc;
  }
</style>

